import fetch from 'common/src/utils/fetch';
import utils from 'common/src/utils/utils';

/**
 * 查询未缴费的课程名单
 */
function findRetraingCharges(data) {
    return fetch({
        url: 'api/electionservice/rebuildCourse/findCourseNoChargeList',
        method: 'post',
        data: data
    });
}

/**
 * 移动到回收站
 */
function moveToRecycle(data) {
    return fetch({
        url:
            '/api/electionservice/rebuildCourse/moveCourseNoChargeListToRecycle',
        method: 'post',
        data: data
    });
}

/**
 * 导出未缴费的课程名单
 */
function exportList(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/export',
        method: 'post',
        data: data
    });
}

/**
 * 导出未缴费的课程名单状态
 */
function exportStatus(key) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/result/'+key,
        method: 'get'
    });
}

/**
 * 批量添加学生异步请求
 */
function getElecRoundStuResult(key) {
    return fetch({
        url: '/api/electionservice/elecRoundStu/result/'+key,
        method: 'get'
    });
}

/**
 * 查询学生重修汇总名单
 */
function getChargeStuList(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/findCourseNoChargeStudentList',
        method: 'post',
        data: data
    });
}
/**
 * 导出学生重修汇总名单
 */
function exportStuList(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/exportStuNumber',
        method: 'post',
        data: data
    });
}

/**
 * 查询回收站
 */
function findRecycleCourse(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/findRecycleCourse',
        method: 'post',
        data: data
    });
}

/**
 * 导出回收站
 */
function exportRecycleCourse(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/exportRecycle',
        method: 'post',
        data: data
    });
}

/**
 * 从回收站回复数据
 */
function moveRecycleToCharge(data) {
    return fetch({
        url:
            '/api/electionservice/rebuildCourse/moveRecycleCourseToNoChargeList',
        method: 'post',
        data: data
    });
}

/**
 * 导出
 */
function exportData(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/student/export',
        method: 'post',
        responseType: 'blob',
        data: data
    }).then(res => {
        utils.downloadFile(
            res,
            'studentRebuilDetails.xls',
            'application/octet-stream'
        );
    });
}

/**
 * 财务对账
 */
function payResult(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/payResult',
        method: 'post',
        data: data
    });
}

/**
 * 缴费订单单条查询
 */
function payDetail(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/payDetail/'+data,
        method: 'get'
    });
}

/**
 * 导出编级退费名单
 */
function exportRefundList(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/exportRefundListBychageGrade',
        method: 'post',
        data: data
    });
}

/**
 * 导出多缴费退费名单
 */
function exportOverpayList(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/exportRefundListByOverpaid',
        method: 'post',
        data: data
    });
}

/**
 * 导出退费退课名单
 */
function exportRefcourseList(data) {
    return fetch({
        url: '/api/electionservice/rebuildCourse/exportRefundListByDropClass',
        method: 'post',
        data: data
    });
}

export default {
    findRetraingCharges: findRetraingCharges,
    moveToRecycle: moveToRecycle,
    exportList: exportList,
    getChargeStuList: getChargeStuList,
    exportStuList: exportStuList,
    findRecycleCourse: findRecycleCourse,
    moveRecycleToCharge: moveRecycleToCharge,
    exportStatus:exportStatus,
    getElecRoundStuResult: getElecRoundStuResult,
    exportRecycleCourse:exportRecycleCourse,
    pageUrl:'api/electionservice/rebuildCourse/student',
    exportData:exportData,
    payResult:payResult,
    payDetail:payDetail,
    exportRefundList: exportRefundList,
    exportOverpayList: exportOverpayList,
    exportRefcourseList: exportRefcourseList
};
